<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	template="/xhtml/bases/base.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:bargas="http://barganhas.com.br/barganhas">

	<ui:define name="baseTitle">
		<h:outputText value="#{siteBean.advertisement.title}"/>
	</ui:define>
	
	<ui:define name="bodyNavigation">
		<!-- title -->
		<h:panelGroup layout="block" id="advertisementDetailTitle" styleClass="advertisementDetailMainHeader">
			<h:outputText value="#{siteBean.advertisement.title}"/>
		</h:panelGroup>
		
		<h:panelGrid columns="2" columnClasses="columnTop, advertisementDetailColumnTop">
			<h:panelGrid>
				<h:panelGroup layout="block" id="wrapperAdvertisementMainPicture">
					<h:graphicImage id="advertisementMainPicture" value="/fileserver?q=#{siteBean.advertisement.sheetPicture.picture.id}"/>
				</h:panelGroup>
				
				<h:panelGroup id="advertisementBoxThumbnails" layout="block">
					<h:panelGroup styleClass="advertisementPictureThumbnail" layout="block">
						<h:graphicImage value="/fileserver?q=#{siteBean.advertisement.sheetPicture.thumbnail.id}"
							onclick="changeSrcImage('advertisementMainPicture', '#{request.contextPath}/fileserver?q=#{siteBean.advertisement.sheetPicture.picture.id}');"/>
					</h:panelGroup>
					
					<ui:repeat var="advertisementPicture" value="#{bargas:getListAsSet(siteBean.advertisement.listAdvertisementPictures)}">
						<h:panelGroup styleClass="advertisementPictureThumbnail" layout="block">
							<h:graphicImage value="/fileserver?q=#{advertisementPicture.thumbnail.id}"
								onclick="changeSrcImage('advertisementMainPicture', '#{request.contextPath}/fileserver?q=#{advertisementPicture.picture.id}');"/>
						</h:panelGroup>
					</ui:repeat>
				</h:panelGroup>
			</h:panelGrid>
			
			<h:panelGrid id="advertisementDetails" style="width: 100%;">
				<!-- description -->
				<bargas:outputText id="description" value="#{msg.privateAreaDescription}" styleClass="advertisementDetailHeader"/>
				<h:panelGroup layout="block" class="advertisementDetails">
					<h:outputText value="#{bargas:textToHtml(siteBean.advertisement.description)}" escape="false"/>
				</h:panelGroup>
				
				<!-- is product new -->
				<bargas:outputText id="isProductNew" value="#{msg.advertisementIsNewProduct}" styleClass="advertisementDetailHeader"/>
				<h:panelGroup layout="block" class="advertisementDetails">
					<h:outputText value="#{siteBean.advertisement.isNewProduct ? msg.advertisementNewProduct : msg.advertisementUseProduct}"/>
				</h:panelGroup>
				
				<!-- user account first name -->
				<bargas:outputText id="userAccount" value="#{msg.advertisementUserAccount}" styleClass="advertisementDetailHeader"/>
				<h:panelGroup layout="block" class="advertisementDetails">
					<h:panelGrid columns="2" style="width: 100%;" columnClasses="columnLeft, columnRight">
						<h:outputText value="#{bargas:getFirstName(siteBean.advertisement.userAccount)}"/>
						<h:commandLink value="#{msg.userAccountViewPublicProfile}" action="#{siteBean.loadUserAccountConsult}">
							<f:setPropertyActionListener target="#{siteBean.userAccount}" value="#{siteBean.advertisement.userAccount}"/>
						</h:commandLink>
					</h:panelGrid>
				</h:panelGroup>
				
				<!-- contact phone numbers 1 -->
				<bargas:outputText id="contactPhoneNumbers" value="#{msg.advertisementContactPhoneNumbers}" styleClass="advertisementDetailHeader" />
				<h:panelGroup layout="block" class="advertisementDetails">
					<h:panelGrid columns="1">
						<h:outputText value="#{siteBean.advertisement.contactPhoneNumberOne}"/>
						<h:outputText value="#{siteBean.advertisement.contactPhoneNumberTwo}"/>
					</h:panelGrid>
				</h:panelGroup>
				
				<!-- contact email -->
				<bargas:outputText id="contactEmail" value="#{msg.advertisementContactMail}:"
					styleClass="advertisementDetailHeader" rendered="#{bargas:isStringOk(siteBean.advertisement.contactEmail)}"/>
				<h:panelGroup layout="block" class="advertisementDetails" rendered="#{bargas:isStringOk(siteBean.advertisement.contactEmail)}">
					<h:outputText value="#{siteBean.advertisement.contactEmail}"/>
				</h:panelGroup>
				
				<!-- localization -->
				<bargas:outputText id="localization" value="#{msg.localizationRegion}" styleClass="advertisementDetailHeader"/>
				<h:panelGroup layout="block" class="advertisementDetails">
					<h:outputText value="#{siteBean.advertisement.userAccount.city.name}"/>
					<h:outputText value=" - " />
					<h:outputText value="#{siteBean.advertisement.userAccount.city.state.name}"/>
				</h:panelGroup>
				
				<!-- listExchangeBy -->
				<bargas:outputText id="listExchangeBy" 
					value="#{msg.advertisementListExchangeBy}" 
					styleClass="advertisementDetailHeader" 
					rendered="#{bargas:isStringOk(siteBean.advertisement.exchangeBy)}"/>
				<h:panelGroup layout="block" 
					class="advertisementDetails" 
					rendered="#{bargas:isStringOk(siteBean.advertisement.exchangeBy)}">
					
					<h:outputText value="#{bargas:textToHtml(siteBean.advertisement.exchangeBy)}" escape="false"/>
				</h:panelGroup>
				
				<!-- value -->
				<bargas:outputText id="value" value="#{msg.privateAreaCurrencyValue}" styleClass="advertisementDetailHeader"/>
				<h:panelGroup layout="block" styleClass="advertisementValueDetails">
					<h:outputText value="#{msg.msgRealCurrency} "/>
					<h:outputText value="#{siteBean.advertisement.value}">
						<f:converter converterId="ConverterDoubleCurrencyReal"/>
					</h:outputText>
				</h:panelGroup>
				
				<iframe src="https://www.facebook.com/plugins/like.php?href=#{siteBean.httpServletRequest.requestURL}?#{siteBean.httpServletRequest.queryString}"
		        	scrolling="no" frameborder="0"
		        	style="border:none; width:450px; height:80px">
	        	</iframe>
			</h:panelGrid>
		</h:panelGrid>
		
		<t:saveState value="#{siteBean.advertisement}"/>
	</ui:define>
</ui:composition>